<template>
  <header class="header">
    <!-- 头部的第一行 -->
    <div class="top">
      <div class="container">
        <div class="loginList">
          <p>
            深圳市
            <span class="el-icon-caret-bottom"></span>
          </p>
        </div>
        <div class="typeList">
          <a href="###">用户名</a>
          <!-- <router-link to="/center">我的订单</router-link> -->
          <span>/</span>
             <router-link to="/login"><span class="el-icon-caret-bottom">请登录</span></router-link>
          <!-- <a href="###"
            >请登录
            <span class="el-icon-caret-bottom"></span>
          </a> -->
          <span>/</span>
          <router-link to="/addcartsuccess">我的购物车</router-link>
          <!-- <a href="###">注册</a> -->
          <router-link to="/register">注册</router-link>
          <span>/</span>
          <a href="###"
            ><i class="iconfont icon-lipin" style="color: #f10180"></i>
            签到有奖</a
          >
          <span>/</span>
          <!-- <a href="###">我的订单</a> -->
          <router-link to="/myorder">我的订单</router-link>
          <span>/</span>
          <a href="###"
            >我的特卖
            <span class="el-icon-caret-bottom"></span>
          </a>
          <span>/</span>
          <a href="###"
            >会员俱乐部
            <span class="el-icon-caret-bottom"></span>
          </a>
          <span>/</span>
          <a href="###">客户服务 </a>
          <span>/</span>
          <a href="###">
            <span class="el-icon-mobile-phone"></span>
            手机版
          </a>
          <span>/</span>
          <a href="###"
            >更多
            <span class="el-icon-caret-bottom"></span>
          </a>
        </div>
      </div>
    </div>
    <!--头部第二行 搜索区域-->
    <div class="bottom">
      <h1 class="logoArea">
        <router-link to="/home" class="logo" title="唯品会">
          <img
            src="https://b.appsimg.com/upload/momin/2020/06/16/82/1592278113502.png"
            alt=""
          />
        </router-link>
      </h1>
      <!-- <div class="text">
        <ul>
          <li class="grantee1"></li>
          <li class="grantee2"></li>
          <li class="grantee3"></li>
        </ul>
      </div> -->
      <div class="logoList">
        <a href="#">1</a>
        <a href="#">2</a>
        <a href="#">3</a>
        <!-- <img src="./images/1587017895494.jpg" alt=""> -->
      </div>
      <div class="searchArea">
        <form action="###" class="searchForm">
          <input
            type="text"
            id="autocomplete"
            class="input-error input-xxlarge"
            v-model="keyword"
          />
          <button
            class="sui-btn btn-xlarge btn-danger iconfont icon-sousuo"
            type="button"
            @click="goSearch"
          ></button>
          <div class="text_cloth">
            <span><a href="">女式大衣</a></span>
            <span class="cut"></span>
            <span><a href="">女靴</a></span>
            <span class="cut"></span>
            <span><a href=""> 女式休闲裤</a></span>
            <span class="cut"></span>
            <span><a href="">波司登BOSIDENG</a></span>
            <span class="cut"></span>
            <span><a href="">护肤套装</a></span>
            <span class="cut"></span>
            <span><a href="">男休闲鞋</a></span>
          </div>
          <button id="goods">
            <div class="el-icon-goods goods_bag">购物袋</div>
            <div class="goodsnum">0</div>
          </button>
        </form>
      </div>
    </div>
  </header>
</template>

<script>
export default {
  name: "Header",
  data() {
    return {
      keyword: undefined,
    };
  },
  methods: {
    goSearch() {
      // 返回一个promise
      this.$router.push({
        name: "search",
        // params传递注意点4：params参数传递不要是空串 地址会错 浏览器回报警告
        // 解决办法：可以传递undefined或null
        // params: {
        //   keyword: this.keyword,
        // },
        // 不管路由对象有没有query 我都带着
        query: {
          keyword: this.keyword,
        },
      });
      // 输入内容发送请求之后 清空文本框的内容
      this.keyword = undefined;
    },
  },
};
</script>

<style lang="less" scoped>
.el-icon-caret-bottom {
  color: #999 !important;
}
.el-icon-mobile-phone {
  color: #000 !important;
}

.header {
  background-color: white;
  & > .top {
    background-color: #eaeaea;
    height: 30px;
    line-height: 30px;

    .container {
      width: 1200px;
      margin: 0 auto;
      overflow: hidden;

      .loginList {
        float: left;
        margin-left: 50px;

        p {
          float: left;
          margin-right: 10px;
          color: #666;

          .register {
            border-left: 1px solid #b3aeae;
            padding: 0 5px;
            margin-left: 5px;
          }
        }
      }
      .typeList {
        float: right;
        span {
          color: #dddddd;
        }
        a {
          padding: 0 10px;
          color: #666;

          & + a {
            border-left: 1px solid #b3aeae;
          }
        }
      }
    }
  }

  & > .bottom {
    width: 1200px;
    margin: -20px auto;
    overflow: hidden;

    .logoArea {
      float: left;
      margin-left: -50px;

      .logo {
        img {
          width: 175px;
          margin: 25px 45px;
        }
      }
    }
    .text {
      margin: 0 auto;
      // width: 1170px;
      background-color: #fff;
      float: left;
      height: 100px;
      clear: both;
      margin-left: 180px;
      margin-top: -130px;

      li {
        float: left;
      }
      .grantee1 {
        background: url("./images/sprites-hash-06206acd.png") no-repeat -4px -39px;
        width: 83px;
        height: 22px;
        margin: 39px 0px 39px 38px;
      }
      .grantee2 {
        background: url("./images/sprites-hash-06206acd.png") no-repeat -105px -39px;
        width: 86px;
        height: 22px;
        margin: 39px 0px 39px 30px;
      }
      .grantee3 {
        background: url("./images/sprites-hash-06206acd.png") no-repeat -208px -41px;
        width: 92px;
        height: 18px;
        margin: 41px 0px 41px 30px;
      }
    }
    .logoList {
      // border: 2px solid blue;
      float: left;
      position: relative;
      left: -30px;
      top: 30px;
      height: 100px;
      width: 300px;
      font-size: 0;
      background-image: url("./images/1587017895494.jpg");
      background-size: contain;
      a {
        // border: 1px solid gold;
        display: inline-block;
        height: 100px;
        width: 100px;
      }
    }
    .searchArea {
      float: right;
      margin-top: 60px;

      .searchForm {
        overflow: hidden;
        // margin-right: 100px;
        input {
          box-sizing: border-box;
          width: 380px;
          height: 35px;
          padding: 0px 4px;
          border: 2px solid #fa2a83;
          float: left;

          &:focus {
            outline: none;
          }
        }

        button:nth-child(2) {
          height: 35px;
          width: 68px;
          background-color: #fa2a83;
          border: none;
          color: #fff;
          float: left;
          cursor: pointer;

          &:focus {
            outline: none;
          }
        }

        #goods {
          height: 35px;
          width: 90px;
          margin-left: 30px;
          border: 1px solid #dddddd;
          position: relative;
        }
        #goods .goods_bag {
          margin-left: -25px;
        }
        #goods .goodsnum {
          position: absolute;
          top: 8px;
          right: 3px;
          border-radius: 8px;
          height: 16px;
          width: 24px;
          line-height: 16px;
          color: #fff;
          // text-align: center;
          background-color: #f00581;
        }
        .text_cloth {
          position: absolute;
          // left: 0px;
          top: 113px;
          // bottom: -32px;

          a {
            font-size: 12px;
            color: #999;
          }
          .cut {
            display: inline-block;
            margin: 0px 5px;
            width: 1px;
            height: 12px;
            background-color: #ccc;
          }
        }
      }
    }
  }
}
</style>
